package com.yzkj.cpjxc.business.domain;

import org.springframework.beans.BeanUtils;

/**
 * 公用JavaBean
 */
public class CommonBean<T> implements Basebean {

	public Class<T> clazz;

	public CommonBean() {
		//		ParameterizedType pt = (ParameterizedType) this.getClass().getGenericSuperclass();
		//		clazz = (Class<T>) pt.getActualTypeArguments()[0];
	}

	/**
	 * 克隆
	 */
	public T copy() {
		//		T target = BeanUtils.instantiate(clazz);
		T target = (T) BeanUtils.instantiate(this.getClass());
		BeanUtils.copyProperties(this, target);
		return target;
	}

	/**
	 * 把值克隆到的目标对象，并返回
	 */
	public T copy(T target) {
		BeanUtils.copyProperties(this, target);
		return target;
	}

	/**
	 * 把值(除了忽略的属性数组)克隆到的目标对象，并返回
	 */
	public T copy(T target, String[] ignoreProperties) {
		BeanUtils.copyProperties(this, target, ignoreProperties);
		return target;
	}

}
